<?php

namespace App\Http\Controllers\Admin;

use App\Models\Fang;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Node;

class IndexController extends Controller
{
    //主页显示
    public function index()
    {
        //获取用户权限
        $auth = session('admin.auth');
        //读取菜单
        $menuData = (new Node())->treeData($auth);
        return view('admin.index.index',compact('menuData'));
    }
    //欢迎页
    public function welcome(Fang $fang)
    {
        //统计数据
        $data = $fang->fangStatusCount();
        return view('admin.index.welcome',$data);
    }
    //退出
    public function logout()
    {
        auth()->logout();
        session(['admin.auth'=>'']);
        return redirect(route('admin.login'))->with('success','退出成功');
    }
}
